package com.example.aicooking.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.aicooking.entity.UserDetail;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
/**
 * 用户详细信息Mapper接口
 *
 * @author 赵鑫
 * @version 1.0
 * @since 2024-03-12
 */
@Mapper
@Repository
public interface UserDetailMapper  extends BaseMapper<UserDetail> {
    UserDetail getUserDetailById(@Param("userId") Long userId);

    // 更新BMI
    void updateBmi(UserDetail userDetail);

    // 更新全部信息
    void updateUserDetail(UserDetail userDetail);

    // 插入新用户健康信息
    @Insert("INSERT INTO user_detail (user_id, bmi, taste, allergen, dietary_restrictions) " +
            "VALUES (#{userId}, #{bmi}, #{taste}, #{allergen}, #{dietaryRestrictions})")
    void insertUserDetail(UserDetail userDetail);
}
